package org.lanqiao.oa.mapper;

import org.lanqiao.oa.vo.PermissionVo;

public class ResultInfo<T> {

    private Boolean status;
    private String errorMsg;
    private T t;

    public ResultInfo() {
    }

    public ResultInfo(Boolean status) {
        this.status = status;
    }

    public ResultInfo(Boolean status, String errorMsg) {
        this.status = status;
        this.errorMsg = errorMsg;
    }

    public ResultInfo(Boolean status, String errorMsg, T t) {
        this.status = status;
        this.errorMsg = errorMsg;
        this.t = t;
    }


    public Boolean getStatus() {
        return status;
    }

    public void setStatus(Boolean status) {
        this.status = status;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public T getT() {
        return t;
    }

    public void setT(T t) {
        this.t = t;
    }

    @Override
    public String toString() {
        return "ResultInfo{" +
                "status=" + status +
                ", errorMsg='" + errorMsg + '\'' +
                ", t=" + t +
                '}';
    }

    /**
     * 获取无参的结果集对象
     * @param flag
     * @return
     */
    public static ResultInfo getResultInfo(boolean flag){
        ResultInfo resultInfo = new ResultInfo(flag);
        if(flag){
            resultInfo.setErrorMsg("操作成功！！");
        }else {
            resultInfo.setErrorMsg("操作失败！！");
        }
        return resultInfo;
    }

    /**
     * 获取无参的结果集对象
     * @param flag
     * @return
     */
    public static ResultInfo getResultInfo(boolean flag,String errorMsg){
        ResultInfo resultInfo = new ResultInfo(flag);
        resultInfo.setErrorMsg(errorMsg);
        return resultInfo;
    }
    /**
     * 获取无参的结果集对象
     * @param flag
     * @return
     */
    public static <T> ResultInfo getResultInfo(boolean flag,String errorMsg,T data){
        ResultInfo resultInfo = new ResultInfo(flag);
        resultInfo.setErrorMsg(errorMsg);
        resultInfo.setT(data);
        return resultInfo;
    }



}
